package com.blog.Bard.base.service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import javax.transaction.Transactional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.blog.Bard.base.dao.BardLabelDao;
import com.blog.Bard.base.pojo.BardLabel;
import com.blog.Bard.common.service.BaseServiceImpl;
import com.blog.Bard.common.util.Pager;

@Service
@Transactional
public class BardLabelServiceImpl extends BaseServiceImpl implements BardLabelService {

	@Autowired
	private BardLabelDao bardLabelDao;
	
	@Override
	public void del(Integer id) throws Exception {
		bardLabelDao.deleteById(id);
	}

	@Override
	public void save(BardLabel t) throws Exception {
		bardLabelDao.save(t);
	}

	@Override
	public BardLabel getOne(Integer id) throws Exception {
		return bardLabelDao.getOne(id);
	}

	@Override
	public Pager pageList(Map<String, Object> params) throws Exception {
		Integer pageNo = (Integer)params.get("pageNo");
		Integer pagesize = (Integer)params.get("pagesize");

		StringBuilder sql = new StringBuilder();
		List<Object> args = new ArrayList<Object>();
		
		sql.append(" select * from BardLabel \n");
		
		return bardLabelDao.getPagerBySql(sql.toString(), pageNo, pagesize, args.toArray());
	}

	@Override
	public List<Map<String, Object>> getAllLabel() throws Exception {
		return bardLabelDao.queryForList("select * from BardLabel where status = 1");
	}

}
